package com.GB26875_3_2011.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @author 蒋仕国
 * @projectName GB26875_3_211
 * @ClassName CommandType
 * @date 2025-01-13 16:13
 * @Description: TODO []
 */

@Getter
@AllArgsConstructor
public enum CommandType {
    COMMAND_00(0, "预留",""),
    COMMAND_01(1, "控制命令","时间同步"),
    COMMAND_02(2, "发送数据","发送火灾报警和建筑消防设施运行状态等信息"),
    COMMAND_03(3, "确认","对控制命令和发送信息的确认回答"),
    COMMAND_04(4, "请求","查询火灾报警和建筑消防设施运行状态等信息"),
    COMMAND_05(5, "应答","返回查询的信息"),
    COMMAND_06(5, "否认","对控制命令和发送信息的否认回答"),
    COMMAND_07(7, "预留【7 - 127】",""),
    COMMAND_128(128, "预留【128-255】","")
    ;

    private final int code;

    private final String name;

    private final String desc;

    public static CommandType getByCode(int code) {
        for (CommandType commandType : CommandType.values()) {
            if (commandType.getCode() == code) {
                return commandType;
            }
        }
        return COMMAND_00;
    }
}
